﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AMS.DD35.DbLoader.Controllers;

namespace AMS.DD35.DbLoader
{
    internal partial class DbLoaderStartForm : Form
    {
        MasterController _controller;

        public DbLoaderStartForm()
            : this(null)
        {
        }

        public DbLoaderStartForm(MasterController controller)
        {
            InitializeComponent();

            _controller = controller;
            _controller.LogoutSucceeded += new EventHandler(HandleLogoutSucceeded);
        }

        private void HandleLogoutSucceeded(object sender, EventArgs e)
        {
            if (this.Visible)
            {
                this.Close();
            }
        }

        protected override void OnClosed(EventArgs e)
        {
            _controller.LogoutSucceeded -= new EventHandler(HandleLogoutSucceeded);
            base.OnClosed(e);
        }

        private void HandleBtnClasses_Click(object sender, EventArgs e)
        {
            _controller.BrowseClasses();
        }

        private void HandleBtnFeats_Click(object sender, EventArgs e)
        {
            _controller.BrowseFeats();
        }

        private void HandleBtnSkills_Click(object sender, EventArgs e)
        {
            _controller.SpawnSkillsEditor();
        }
    }
}
